<template>
	<el-dialog :title="dialogTitle" :visible.sync="visible" width="800px">
		<el-row class="user_detail_wrapper">
			<el-col :span="8">
				<el-avatar :size="50" :src="squareUrl"></el-avatar>
			</el-col>
			<el-col :span="8">
				<h4>用户账号</h4>
				<p></p>
			</el-col>
			<el-col :span="8">
				<h4>用户昵称</h4>
				<p></p>
			</el-col>
		</el-row>
	</el-dialog>
</template>

<script>
import { userDetail } from '@/api/system/tbSysUser';
export default {
	enums: ['USER_TYPE'],
	props: {
		value: { type: Boolean, default: false },
		data: { type: Object, default: () => {} }
	},
	data() {
		return {
			visible: this.value,
			userData: {},
			squareUrl: ''
		};
	},
	computed: {
		dialogTitle() {
			return `用户【${this.data.userName}】详情`;
		}
	},
	watch: {
		value(flag) {
			this.visible = flag;
		},
		visible(flag) {
			this.$emit('input', flag);
			if (!flag) return false;
			this.loading = true;
			this.getUserDetailData(this.data.id);
		}
	},
	methods: {
		//获取用户详情
		async getUserDetailData(id) {
			let result = await userDetail(id).then((res) => res.data);
			this.loading = false;
			if (result.code === '0') {
				this.userData = !!result.data && result.data.length > 0 ? result.data[0] : {};
				console.log(this.userData);
			}
		},

		//用户类型
		userTypeFilter(value) {
			let info = this.dictData['USER_TYPE'].find((item) => item.value === value);
			return !info ? value : info.msg;
		}
	}
};
</script>

<style lang="scss" scoped>
.user_detail_wrapper::v-deep {
	flex: 1;
	.el-col {
		padding: 10px;
		border-top: solid 1px #ccc;
	}
}
</style>
